home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / magazine / dbms_mag / 9102 / foxpro3.feb < prev    next >
Text File  |  1990-12-19  |  1KB  |  38 lines

  1.  
  2. PROCEDURE FindStr.prg
  3. ************************************************************
  4. * Program ...: FindStr.prg
  5. * Author     :  P. L. Olympia & Kathy Cea
  6. * Purpose....: Searches a text file for the Nth occurrence of
  7. *            : a specified string using FoxPro memo field
  8. *            : commands/functions
  9. * Syntax ....: DO FindStr WITH <string>, <txtfile>, <Noccur>
  10. * Notes .....: Assumes .dbf in current area has memo field
  11. *            :  called MemFld
  12. ************************************************************
  13. PARAMETERS string, txtfile, Noccur
  14.  
  15. *-- Make sure file exists
  16.  
  17. IF !FILE((txtfile))
  18.    ? "Can't seem to find " + txtfile
  19.    RETURN
  20. ENDIF
  21.  
  22. Noccur = IIF(Noccur < 1, 1, Noccur)    && Can't be < 1
  23.  
  24. *-- Load the file to the memo field
  25. APPEND MEMO memfld FROM (txtfile) OVERWRITE
  26.  
  27. *-- Search the memo field for the string
  28. start = ATC(string, memfld, Noccur)
  29. IF start = 0
  30.    ? string + 'not found'
  31. ELSE
  32.    *  Display string highlighted in window
  33.    long = start + LEN(string)
  34.    MODIFY MEMO memfld NOEDIT RANGE start, long
  35. ENDIF
  36. RETURN
  37.  
  38.